/*
 * @Date: 2023-02-15 16:07:01
 * @LastEditTime: 2023-03-31 18:33:47
 * @FilePath: /NLK/src/api/module/sys.ts
 * 介绍:系统接口,公共接口
 */
import { defaHttp, ApiRes } from "../index";

/**登录 */
export async function apiLogin(data: Login.Req): Promise<void | Login.Res> {
  const res = await defaHttp.post<ApiRes<Login.Res>>("/connect", data, {
    mode: ["removeReqVoid", "showError"],
  });
  if (res.code !== 200) return;
  return res.data;
}

/**登录 */
export namespace Login {
  export interface Req {
    /**客户端ID */
    clientId: Id;
    /**56：bsc；100：trx */
    chainId: Id;
    nwtworkId: Id;
    /**用户地址 */
    accounts: string;
    /**邀请码 */
    invit?: string;
    /**当前钱包名 */
    that_wallet_name: string;
    code: string;
  }
  export interface Res {
    access_token: string;
    token_type: string;
    expires_in: number;
  }
}
/**获取授权地址 */
export async function apiAutoAddress(
  data: AutoAddress.Req
): Promise<void | AutoAddress.Res> {
  const res = await defaHttp.post<ApiRes<AutoAddress.Res>>(
    "/auth/address",
    data
  );
  if (res.code !== 200) return;
  return res.data;
}
/**获取授权地址 */
export namespace AutoAddress {
  export interface Res {
    address: string;
  }
  export interface Req {
    /**56：bsc；100：TRX； */
    chain: number;
  }
}

/**获取充币地址 */
export async function apiTopUpAddress(): Promise<void | TopUpAddress.Res> {
  const res = await defaHttp.post<ApiRes<TopUpAddress.Res>>(
    "/wallet/bscaddress",
    undefined
  );
  if (res.code !== 200) return;
  return res.data;
}
/**获取充币地址 */
export namespace TopUpAddress {
  export interface Res {
    address: string;
  }
  // export interface Req {
  //   /**56：bsc；100：TRX； */
  //   chain: number;
  // }
}
